package com.study.d012Components;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.FontSmoothingType;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;

/** Text控件和Font控件的使用
*@description
*@author xtayhame
*date 2020年3月14日
*version
*since v1.0
*/
public class TextAndFontMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		VBox vBox = new VBox(10);
		Text text01 = new Text("1. Hello World.");
		System.out.println("默认字体："+text01.getFont().getFamily());   //System

		Text text02 = new Text("2. Hello World.");
		Font font02 = new Font("华文彩云", 20);
		text02.setFont(font02);

		Text text03 = new Text("3. Hello World. 这个世界不太友好哦，赶快逃离星球吧");
		Font font03= text03.getFont();
		text03.setTextOrigin(VPos.BOTTOM);
		//设置平滑
		text03.setFontSmoothingType(FontSmoothingType.LCD);
		//设置是否抗锯齿
		text03.setSmooth(true);
		text03.setTextAlignment(TextAlignment.CENTER);
		//设置每行显示多少个
		text03.setWrappingWidth(100);
		//显示下划线
		text03.setUnderline(true);
		//设置中间线
		text03.setStrikethrough(true);

		//设置字体颜色
		text03.setFill(Paint.valueOf("Red"));

		//设置描边颜色
		text03.setStroke(Paint.valueOf("#CD5C5C"));

		//设置描边的宽度
		text03.setStrokeWidth(2);


	/*	System.out.println("打印所有字体：");
		for(String s:Font.getFamilies()){
			System.out.println(s);
		};*/

		vBox.getChildren().addAll(text01,text02,text03);
		anchorPane.getChildren().add(vBox);
		AnchorPane.setTopAnchor(vBox, 10.0);
		AnchorPane.setLeftAnchor(vBox, 10.0);
		stage.setScene(new Scene(anchorPane, 400, 300));
		stage.show();
	}
}
